<template>
	<div class="vi-empty py-20 text-center">
		<el-result :icon="icon" :title="title" :sub-title="description">
			<template #extra>
				<el-button type="primary" @click="onClickBtn">返回首页</el-button>
			</template>
		</el-result>
	</div>
</template>
<script setup lang="ts">
import type { PropType } from 'vue'
import { useRouter } from 'vue-router'

const props = defineProps({
	title: {
		type: String,
		default: () => '页面找不到啦',
	},
	description: String,
	icon: {
		type: String as PropType<'success' | 'error' | 'info' | 'warning'>,
		default: () => 'error2',
	},
	onClickBack: Function,
})

const router = useRouter()

const onClickBtn = () => {
	if (props.onClickBack) props.onClickBack()
	else router.go(-1)
}
</script>
